<?php
/**
 * Created by Zhy
 * User: Zhy
 * Date: 2018/8/3
 * Time: 15:14
 */

namespace app\api\controller;

use app\api\model\Corps as CorpsModel;
use app\api\model\InstitutionalActivities as InstitutionalActivitiesModel;

class Corps extends Common
{
    /**
     * 总队
     */
    public function corpsInfo(){
        $params = input('param.');
        $res = $this->checkAll($params['user_id'], $params['time'], $params['value'], $params['reqKey']);
        if($res == false) {
            return $this->apiError(301);
        }
        $corpsModel = new CorpsModel();
        $info = $corpsModel->getCorpsInfo();
        
        $institutionalActivitiesModel = new InstitutionalActivitiesModel();
        $total = $institutionalActivitiesModel->totals();
        
        if(! $total[0]['totalTime']){
            $info['totalTime'] = 0;//总时长
        }else{
            $info['totalTime'] = $total[0]['totalTime'];
        }
        $info['totalNum'] = $total[0]['totalNum'];//总次数
        return $this->apiSuccess($info);
    }
}